#define _GNU_SOURCE
#include "app_pool.h"
#include "log/log.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int task(void *arg) {
    char *name = (char *) arg;
    log_info("Task %s is running,tid=%ld", name, gettid());
    free(name);
}

int main(int argc, char *argv[]) {
    
    app_pool_init(5); // 初始化线程池，线程池大小为5

    for (int i = 0; i < 10; ++i) {
        char *name = (char *) malloc(10);
        sprintf(name, "task-%d", i);
        app_pool_registerTask(task, name);
    }

    sleep(1);
    app_pool_close(); // 销毁线程池
    log_debug("main thread exit");
    return 0;
}